﻿Public Class FrmChiTietPhieuXuat

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnLapPhieu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLapPhieu.Click
        FrmLapPhieuXuat.ShowDialog()
    End Sub

   Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim iMaPhieuXuat As Integer = txtMaPhieuXuat.Text
        Dim px As PhieuXuatDTO = PhieuXuatDAO.SelectByID(iMaPhieuXuat)

        dtpNgayXuat.Value = px.NgayXuat

        LoadDSTim()
        LoadTongGiaTriPhieuXuat()
    End Sub

    Sub LoadLenLuoi()

        Dim ds As DataTable
        ds = PhieuXuatDAO.SelectAll()
        dgvDSChiTietPhieuXuat.DataSource = ds

    End Sub

    Public Sub LoadDSTim()
        Dim iMaPhieuXuat As Integer = txtMaPhieuXuat.Text
        Dim ds As DataTable
        ds = PhieuXuatDAO.SelectAllCTPX(iMaPhieuXuat)
        dgvDSChiTietPhieuXuat.DataSource = ds
    End Sub

    Private Sub FrmChiTietPhieuXuat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadLenLuoi()
    End Sub

    Public Sub LoadTongGiaTriPhieuXuat()
        Try
            txtTongTien.Text = PhieuXuatDAO.TotalValue(txtMaPhieuXuat.Text) & " VND"
        Catch ex As Exception
            txtTongTien.Text = "0 VND"
        End Try


    End Sub
End Class